package com.shyroke.daydayzhuanapi.entity;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Set;

@Getter
@Setter
@Entity
@Table(name = "project")
public class ProjectEntity extends BaseEntity implements Serializable {

    private String title;

    private String projectName;

    private String summary;

    private String cover;

    private Date createTime;

    private Integer readMount;


    private Integer todayAppReadCount;
    private Integer todayReadCount;

    private Integer commentMount;

    private Integer likes;

    private Integer dips;

    @Column(name = "create_id")
    private Integer createId;

    private String type;

    private String content;

    private String commented = "0";

    private String offline ;

    private String keyword;

    private String keywords;

    private Date updateTime;

    private String isHomePage;

    private Integer isNofollow;

    private String source;

    private Integer projectId;

    @Column(name = "type_id")
    private Integer typeId;

    @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.PERSIST)
    @JoinColumn(name = "type_id",referencedColumnName = "id",insertable = false, updatable = false)
    private TypeEntity typeObj;

    @ManyToMany(cascade = CascadeType.PERSIST)
    @JoinTable(name = "project_label",
            joinColumns = @JoinColumn(name = "projectid"),
            inverseJoinColumns = @JoinColumn(name = "labelid",insertable = false,updatable = false))
    private List<LabelEntity> labelList;

    @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.PERSIST)
    @JoinColumn(name = "create_id",referencedColumnName = "id",insertable = false, updatable = false)
    private UserEntity user;

    @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.PERSIST)
    @JoinColumn(name = "app_id",referencedColumnName = "id",insertable = false, updatable = false)
    private AppEntity app;

    @ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinTable(name = "project_subject",joinColumns = @JoinColumn(name = "project_id",insertable = false, updatable = false),
            inverseJoinColumns = @JoinColumn(name = "subject_id",insertable = false, updatable = false))
    private List<SubjectEntity> subjectList;

    @ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinTable(name = "project_app",joinColumns = @JoinColumn(name = "project_id",insertable = false, updatable = false),
            inverseJoinColumns = @JoinColumn(name = "app_id",insertable = false, updatable = false))
    private List<AppEntity> appList;

    /**
     * 免费赚
     */
    @Column(name = "profit")
    private BigDecimal profit;

    private Integer sortIndex;

    private String showLabel;

    @Transient
    private String showCreateTime;
    @Transient
    private String showEndTime;
    @Transient
    private String isToday;
    @Transient
    private String labels;
    @Transient
    private String url;
    @Transient
    private String isTemp;
    @Transient
    private String sourceURL;
    @Transient
    private Integer spiderProjectId;
    @Transient
    private String showSinaSummary;
}